import { reqCustomerInfo } from "../../api/profile";

// pages/profile/profile.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    avatarUrl:"",
    nickName:"微信用户"

  },

  navigateToPointMall:function(){
    wx.navigateTo({
      url: '/pages/pointmall/pointmall',
    })
  },


  navigateToClientService: function () {
    const { avatarUrl, nickName } = this.data;  // 获取当前头像和昵称
    wx.navigateTo({
      url: `/pages/clientservice/clientservice?avatarUrl=${encodeURIComponent(avatarUrl)}&nickName=${encodeURIComponent(nickName)}`
    });
  },

  navigateToAttention:function(){
    wx.navigateTo({
      url: '/pages/attention/attention',
    })
  },

  navigateToAddress: function() {
    wx.navigateTo({
      url: '/pages/address/address',
    })
  },


  navigateToInfoEdit:function(){
    wx.navigateTo({
      url: '/pages/infoedit/infoedit',
    })
  },

  navigateToOrder:function(e){
    const active=e.currentTarget.dataset.active;
    console.log(active);
    wx.navigateTo({
      url: `/pages/order/order?active=${active}`,
    })
  },

  onShow(){
    this.getCustomerInfo()
  },

  async getCustomerInfo(){
    const {data} = await reqCustomerInfo()
    this.setData({
      avatarUrl:data.customerAvatar,
      nickName:data.customerName
    })
  },

  navigateToLiveManage(){
    wx.navigateTo({
      url: '/pages/livemanage/livemanage',
    })
  }

  
  
})
